package com.shopping.response;

import com.sun.tools.javac.jvm.Code;
import lombok.AllArgsConstructor;
import lombok.Data;

@Data
@AllArgsConstructor
public class CodeMsg {
    private Integer code;
    private String message;

    public static CodeMsg SUCCESS=new CodeMsg(0,"success");
    public static CodeMsg SERVER_ERROR=new CodeMsg(500100,"服务器异常");
    public static CodeMsg BIND_ERROR=new CodeMsg(500101,"参数校验异常：%s");
    //登录
    public static CodeMsg PASSWORD_EMPTY=new CodeMsg(500211,"密码不能为空");
    public static CodeMsg MOBILE_EMPTY=new CodeMsg(500212,"手机号不能为空");
    public static CodeMsg MOBILE_ERROR=new CodeMsg(500213,"手机号格式错误");
    public static CodeMsg MOBILE_NOT_EXISTS=new CodeMsg(500214,"手机号不存在");
    public static CodeMsg PASSWORD_ERROR=new CodeMsg(500214,"密码错误");
    public static CodeMsg MIAO_SHA_ERROR=new CodeMsg(500500,"商品已经秒杀完毕");
    public static CodeMsg REPEART_MIAOSHA=new CodeMsg(500501,"不能重复秒杀");

    public CodeMsg findArgs(Object...objects){
        Integer code=this.code;
        String message=String.format(this.message,objects);
        return new CodeMsg(code,message);
    }

}
